<?php

declare(strict_types=1);

namespace App\WorkContact\Controller\Dashboard\Room;

use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\Middleware;
use Hyperf\HttpServer\Annotation\Middlewares;
use Hyperf\HttpServer\Annotation\RequestMapping;
use App\Common\Middleware\DashboardAuthMiddleware;
use App\WorkContact\Logic\Room\OwnerLogic;
use Base\Action\AbstractAction;
use Base\Request\ValidateSceneTrait;

/**
 * 客户群群主-列表.
 *
 * Class Owner.
 * @Controller
 */
class Owner extends AbstractAction
{
    use ValidateSceneTrait;

    /**
     * @Inject
     * @var OwnerLogic
     */
    protected $indexLogic;

    /**
     * @RequestMapping(path="/dashboard/workContactRoom/owner", methods="get")
     * @Middlewares({
     *     @Middleware(DashboardAuthMiddleware::class),
     * })
     * @return array 返回数组
     */
    public function handle(): array
    {
        ## 接收参数
        $params = [
            'status' => $this->request->input('status'),
            'name' => $this->request->input('name'),
            'startTime' => $this->request->input('startTime'),
            'endTime' => $this->request->input('endTime'),
            'page' => (int)$this->request->input('current', 1),
            'perPage' => (int)$this->request->input('size', '10'),
        ];
        $params['page'] = $params['page']<1?1:$params['page'];
        $params['perPage'] = $params['perPage']<1?10:$params['perPage'];
        $params['corpId'] = $this->request->input('userInfo.corp_id');
        $params['tenantId'] = $this->request->input('userInfo.tenant_id');
        $params['userId'] = $this->request->input('userInfo.user_id');
        $params['deptId'] = $this->request->input('userInfo.dept_id');
        return $this->indexLogic->handle($params);
    }
}
